// 用户角色枚举
export enum UserRole {
  SUPER_ADMIN = 'super_admin',    // 超级管理员
  ORDER_ADMIN = 'order_admin',    // 订单管理员
  CATEGORY_ADMIN = 'category_admin', // 分类管理员
  PRODUCT_ADMIN = 'product_admin'  // 商品管理员
}

// 用户状态枚举
export enum UserStatus {
  ACTIVE = 'active',    // 正常
  DISABLED = 'disabled' // 禁用
}

// 用户权限接口
export interface UserPermission {
  canManageUsers: boolean;      // 是否可以管理用户
  canManageOrders: boolean;     // 是否可以管理订单
  canManageCategories: boolean; // 是否可以管理分类
  canManageProducts: boolean;   // 是否可以管理商品
}

// 根据角色获取权限
export const getRolePermissions = (role: UserRole): UserPermission => {
  switch (role) {
    case UserRole.SUPER_ADMIN:
      return {
        canManageUsers: true,
        canManageOrders: true,
        canManageCategories: true,
        canManageProducts: true,
      };
    case UserRole.ORDER_ADMIN:
      return {
        canManageUsers: false,
        canManageOrders: true,
        canManageCategories: false,
        canManageProducts: false,
      };
    case UserRole.CATEGORY_ADMIN:
      return {
        canManageUsers: false,
        canManageOrders: false,
        canManageCategories: true,
        canManageProducts: false,
      };
    case UserRole.PRODUCT_ADMIN:
      return {
        canManageUsers: false,
        canManageOrders: false,
        canManageCategories: false,
        canManageProducts: true,
      };
    default:
      return {
        canManageUsers: false,
        canManageOrders: false,
        canManageCategories: false,
        canManageProducts: false,
      };
  }
};

// 用户信息接口
export interface User {
  id: number;
  username: string;
  email: string;
  phone: string;
  role: UserRole;
  status: UserStatus;
  createdAt: string;
  lastLoginAt: string;
}

// 用户表单数据接口
export interface UserFormData {
  username: string;
  email: string;
  phone: string;
  password?: string; // 仅在创建时必填
  role: UserRole;
  status: UserStatus;
}

// 用户列表查询参数接口
export interface UserQueryParams {
  keyword?: string;
  role?: UserRole;
  status?: UserStatus;
  page: number;
  pageSize: number;
}

// 用户列表响应接口
export interface UserListResponse {
  total: number;
  items: User[];
} 